/*
 * Copyright (c) 2018.
 * 北京九思金信科技有限公司对该文件内容保留所有权利。
 * 未经许可，不得私自拷贝、传播、发布、引用该文件内容，违者将被追究法律责任。
 */

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import VueResource from 'vue-resource'
import store from './store'
import utils from '../../utils'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import JoysUI from 'joys-ui'
import FrameBus from 'joys-frame-bus'
import JoysBpmUI from 'joys-bpm-ui'
// import JoysDecisionUI from 'joys-decision-ui'
import NclsUI from 'ncls-ui'

Vue.use(FrameBus)
Vue.use(JoysUI)
Vue.use(VueResource)
Vue.use(JoysBpmUI)
// Vue.use(JoysDecisionUI)
Vue.use(NclsUI)
Vue.use(ElementUI)

Vue.config.productionTip = false
Vue.http.options.timeout = 600000
Vue.http.headers.common['AUTH-TOKEN'] = localStorage.getItem('AUTH-TOKEN')
Vue.http.interceptors.push((request, next) => {
    next(response => {
        if(response.ok && response.status == 200) {
            return response
        }
        return Promise.reject(response)
    })
})


Vue.prototype.$utils = utils
/**
 *默认主题设定
 */
if (localStorage.getItem('current-theme') == null) {
    localStorage.setItem('current-theme', 'theme-blue')
}
if (localStorage.getItem('AUTH-TOKEN') == null) {
    localStorage.setItem('AUTH-TOKEN', '请录入token，否则请求报401或者会话未登陆')
}

import(`joys-ui/theme/${localStorage.getItem('current-theme')}/index.css`).then(
    () => {
        new Vue({router, store, render: h => h(App)}).$mount('#app')
    }
)
